<?php
/**
 * controller file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2019/09/04
 * Time: 17:52
 */
 namespace Modules\Admin\Http\Controllers;

use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\OrderCheckpointService;

class OrderCheckpointController extends BaseController
{


//    /**
//     *  XXX 列表
//     *
//     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
//     * @author wumengmeng <wu_mengmeng@foxmail.com>
//     */
//    public function index()
//    {
//        $arr_search = (array) Request::all();
//        $res = OrderCheckpointService::get_list( (array) $arr_search );
//        echo_error($res);
//        return view('admin::order.checkpoint_index', $res['data']);
//    }

    /**
     *  年检预约订单 列表 - 全部
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function index()
    {
        $arr_input = Request::input();
        $res = OrderCheckpointService::all_order_list($arr_input);
        echo_error($res);
        return view('admin::order.checkpoint_index', $res['data']);
    }



    /**
     * 添加 XXX 页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function create()
    {
        return view('admin::order_checkpoint.create');
    }

    /**
     * 添加 XXX 操作
     *
     * @return mixed
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function store()
    {
        $arr_input = Request::input();
        $arr_input['operator_id'] = (int)admin_user_id();
        return OrderCheckpointService::add_one($arr_input);
    }

    /**
     * 修改 XXX 页面
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function edit()
    {
        $nId = Request::get('id',0);
        $res = OrderCheckpointService::get_one((int)$nId);
        echo_error($res);

        $arr_data = [
          'arr_data'=>$res['data'],
        ];
        return view('admin::order_checkpoint.edit',$arr_data);
    }

    /**
     * 修改 XXX 页面操作
     *
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function update()
    {
        $arr_input = Request::input();
        $arr_input['operator_id'] = (int)admin_user_id();
        return OrderCheckpointService::edit_one($arr_input);
    }


    /**
     * 更改 XXX 状态
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function change_state()
    {
        $arr_input = Request::input();
        return OrderCheckpointService::change_one_state($arr_input);
    }

    /**
     * 删除 XXX 
     *
     * @return array|\Illuminate\Http\RedirectResponse
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function delete()
    {
        $n_id = (int)Request::get('id',0);
        return OrderCheckpointService::delete_one($n_id);
    }
}